<?php

namespace App\Http\Requests\finance;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait TransferGetRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'customer_id' => 'required|integer',
            'account_id' => 'required|integer',
            'take_order_sn' => 'required',
            'amount' => 'required',
            'files' => 'required',
        ], [
            'customer_id.required' => '请选择客户',
            'account_id.required' => '请选择收款账户',
            'take_order_sn.required' => '请填写收款提单',
            'amount.required' => '请填写收款金额',
            'files.required' => '请选择上传附件'
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
